import time

from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service as FirefoxService
# 自动下载对应的驱动
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
#最大化窗口
driver.maximize_window()
driver.get("https://www.baidu.com/")
# 绝对定位
driver.find_element(By.XPATH, '/html/body/div/div/div[3]/a').click()
# 通过ID定位
driver.find_element(By.XPATH, "//input[@id='kw']").send_keys("dddkk")
# 多级元素定位
driver.find_element(By.XPATH, "//div[@id='s-top-left']/a[4]").send_keys("dddkk")


time.sleep(10)

driver.close();